/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.pay.db.impl;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.pay.model.ReportModel1;
import com.yunhoo.pay.model.VouCheckInfo;
import com.yunhoo.sys.db.util.IbatisTemplate;
import com.yunhoo.sys.util.common.LoginParam;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author admin
 */
public class VoucherPubImpl {

    private final static String NAMESPACE = "voucher.";

    public static void insertCheckInfo(VouCheckInfo checkInfo) {
        SqlMapClient client = IbatisTemplate.getSqlMapClient();
        try {
            client.startTransaction();
            client.delete(NAMESPACE + "deleteCheckInfo", checkInfo);
            client.insert(NAMESPACE + "insertCheckInfo", checkInfo);
            client.commitTransaction();
        } catch (SQLException ex) {
            try {
                client.endTransaction();
            } catch (SQLException ex1) {
                Logger.getLogger(VoucherPubImpl.class.getName()).log(Level.SEVERE, null, ex1);
            }
        }
    }

    public static void deleteCheckInfo(VouCheckInfo checkInfo) {
        IbatisTemplate.delete(NAMESPACE + "deleteCheckInfo", checkInfo);
    }

    public static List<ReportModel1> queryTotal1(Map map) {
        if (map == null) map = new HashMap();
        map.put("orgCode", LoginParam.getOrg().getCode());
        map.put("iyear", LoginParam.getIyear());
        return IbatisTemplate.queryForList("voucher.queryTotal1", map);
    }
}
